package com.dss.enums;


import java.util.HashMap;
import java.util.Map;

public enum AccidentKind {
	NATURE(1, "自然事故"),
	RESPONSIBILITY(2, "责任事故");
	
	private int value;
	private String title;

	AccidentKind(int value, String title) {
		this.value = value;
		this.title = title;
	}

    /**
     * 获取枚举值
     * @return 返回枚举值
     */
	public int value() {
		return this.value;
	}

    /**
     * 获取枚举标题
     * @return 返回枚举的标题
     */
	public String title() {
		return this.title;
	}

	private static Map<String, AccidentKind> titlefinder;
	static {
		titlefinder = new HashMap<String, AccidentKind>();
		for (AccidentKind item : AccidentKind.values())
			titlefinder.put(item.title(), item);

	}

	private static Map<Integer, AccidentKind> valuefinder;
	static {
		valuefinder = new HashMap<Integer, AccidentKind>();
		for (AccidentKind item : AccidentKind.values())
			valuefinder.put(new Integer(item.value()), item);

	}

	/**
	 * 按照枚举值查找枚举
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static AccidentKind valueOf(int type) {
		return valuefinder.get(new Integer(type));
	}
	
	/**
	 * 按照枚举标题查找枚举值
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static AccidentKind titleOf(String title) {
		return titlefinder.get(title);
	}
	
	public static AccidentKind[] getMembers() {
		return new AccidentKind[] {NATURE, RESPONSIBILITY};
	}
}
